package com.iuie.ns.devtools.element;

import com.iuie.ns.devtools.to.ResultMapDevHeaderTO;
import com.iuie.ns.frame.utils.StringUtils;

public abstract class JavaMapperClassDevElement extends DevElement {
	
	private ResultMapDevHeaderTO header;
	
	public JavaMapperClassDevElement(ResultMapDevHeaderTO header) {
		this.header = header;
	}

	@Override
	protected String getPrefix() {
		StringBuilder sb = new StringBuilder(12);
		// 拼接包路径
		if (StringUtils.isNotBlank(header.getPackagePath())) {
			sb.append("package " + header.getPackagePath() + ".mapper" + ";\n\n");
		}
		// 导包
		sb.append("import java.util.List;\n")
			.append("import java.util.Date;\n")
			.append("import org.apache.ibatis.annotations.Param;\n");
		// 类
		sb.append("\n@MyBatisRepository")
			.append("\npublic interface ")
			.append(header.getSimpleClassName())
			.append("Mapper")
			.append(" {\n\n");
		return sb.toString();
	}

	@Override
	protected String getSuffix() {
		return "}";
	}

}
